#ifndef __COMPONENT_SLEEP_H__
#define __COMPONENT_SLEEP_H__

#include "Component.hpp"

namespace PocketSurvival
{
    struct ComponentPlayer;
    struct ComponentSleep : public Component
    {
        double sleepStartTime = 0.0;
        bool allowManualWakeUp;
        float minWetness;

        ComponentPlayer *componentPlayer;

        virtual bool canSleep(std::string &reason);
        virtual void sleep(bool canWakeUp);
        virtual void netSleep(bool canWakeUp);
        virtual void wakeUp();
        virtual void netWakeUp();

        inline bool isSleeping();

        virtual void update(float dt) override;
        virtual const std::string &getName() const override;
        static const std::string &GetName();
        virtual void load(const nlohmann::json &jsonData) override;
        virtual void save(nlohmann::json &jsonData) override;
        virtual void saveToMsgJson(nlohmann::json &jsonData) override;
    };
    
    inline bool ComponentSleep::isSleeping()
    {
        return sleepStartTime > 0.0f;
    }

} // namespace PocketSurvival

#endif
